using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
//using ModulDuoc.BusinessLayer.DataLayer;
using BE;
using DAL;

namespace BC//ModulDuoc.BusinessLayer
{
    public class ZD_DonMauCTBC//Factory
    {

        #region data Members

        ZD_DonMauCTSql _dataObject = null;

        #endregion

        #region Constructor

        public ZD_DonMauCTBC()//Factory()
        {
            _dataObject = new ZD_DonMauCTSql();
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Insert new ZD_DonMauCT
        /// </summary>
        /// <param name="businessObject">ZD_DonMauCT object</param>
        /// <returns>true for successfully saved</returns>
        public bool Insert(ZD_DonMauCT businessObject)
        {
            if (!businessObject.IsValid)
            {
                throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Insert(businessObject);

        }

        /// <summary>
        /// Update existing ZD_DonMauCT
        /// </summary>
        /// <param name="businessObject">ZD_DonMauCT object</param>
        /// <returns>true for successfully saved</returns>
        public bool Update(ZD_DonMauCT businessObject)
        {
            if (!businessObject.IsValid)
            {
                throw new InvalidBusinessObjectException(businessObject.BrokenRulesList.ToString());
            }


            return _dataObject.Update(businessObject);
        }

        /// <summary>
        /// get ZD_DonMauCT by primary key.
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>Student</returns>
        public ZD_DonMauCT GetByPrimaryKey(ZD_DonMauCTKeys keys)
        {
            return _dataObject.SelectByPrimaryKey(keys); 
        }

        /// <summary>
        /// get list of all ZD_DonMauCTs
        /// </summary>
        /// <returns>list</returns>
        public List<ZD_DonMauCT> GetAll_List()
        {
            return _dataObject.SelectAll_List(); 
        }

        /// <summary>
        /// get list of ZD_DonMauCT by field
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>list</returns>
        public List<ZD_DonMauCT> GetAllBy_List(ZD_DonMauCT.ZD_DonMauCTFields fieldName, object value)
        {
            return _dataObject.SelectByField_List(fieldName.ToString(), value);  
        }
//them - hiennv
        public DataTable GetAll()
        {
            return _dataObject.SelectAll(); 
        }

        public DataTable GetAllBy(ZD_DonMauCT.ZD_DonMauCTFields fieldName, object value)
        {
            return _dataObject.SelectByField(fieldName.ToString(), value);  
        }
//end them - hiennv

        /// <summary>
        /// delete by primary key
        /// </summary>
        /// <param name="keys">primary key</param>
        /// <returns>true for succesfully deleted</returns>
        public bool Delete(ZD_DonMauCTKeys keys)
        {
            return _dataObject.Delete(keys); 
        }

        /// <summary>
        /// delete ZD_DonMauCT by field.
        /// </summary>
        /// <param name="fieldName">field name</param>
        /// <param name="value">value</param>
        /// <returns>true for successfully deleted</returns>
        public bool Delete(ZD_DonMauCT.ZD_DonMauCTFields fieldName, object value)
        {
            return _dataObject.DeleteByField(fieldName.ToString(), value); 
        }

        #endregion

    }
}
